package es.mahulo.battleship.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import es.mahulo.battleship.api.dao.ShipConfigDao;
import es.mahulo.battleship.model.Game;
import es.mahulo.battleship.model.ShipConfig;

@Repository
public class ShipConfigDaoImpl implements ShipConfigDao {
	private EntityManager entityManager;
	@PersistenceContext  
    public void setEntityManager(EntityManager entityManager)   {  
		this.entityManager = entityManager;  
    }  


	@Override
	@Transactional
	public List<ShipConfig> getAll() {
		Query q = entityManager.createQuery("SELECT c FROM ShipConfig c",ShipConfig.class);
		return q.getResultList();
	}

}
